﻿using System;
using System.Collections;
using System.Collections.Specialized;
using System.Linq.Expressions;
using Castle.MonoRail.Framework;

namespace Castle.MonoRail.ExtensionMethods {
	public static class IUrlBuilderExtensions {
		public static IUrlBuilderExtensionsProvider Provider { get; set; }

		static IUrlBuilderExtensions() {
			Provider = new DefaultExtensionsProvider();
		}

		public static string BuildUrl<T>(this IUrlBuilder self, UrlInfo current, Expression<Action<T>> action)
			where T : Controller {
			return Provider.BuildUrl(self, current, action);
		}

		public static string BuildUrlWithParams<T>(this IUrlBuilder self, UrlInfo current, Expression<Action<T>> action)
			where T : Controller {
			return Provider.BuildUrlWithParams(self, current, action);
		}

		public static string BuildUrl<T>(this IUrlBuilder self, UrlInfo current, Expression<Action<T>> action,
		                                 IDictionary parameters) where T : Controller {
			return Provider.BuildUrl(self, current, action, parameters);
		}

		public static string BuildUrl<T>(this IUrlBuilder self, UrlInfo current, Expression<Action<T>> action,
		                                 NameValueCollection parameters) where T : Controller {
			return Provider.BuildUrl(self, current, action, parameters);
		}
	}
}